<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>星星特效 </title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        div {
            line-height: 24px;
        }

        li {
            width: 24px;
            height: 24px;
            background: url(./star.png) no-repeat;
            background-size: 24px 24px;
            float: left;
            list-style: none;
            margin: 5px;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <div>
        <ul>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
        <span></span>
    </div>
</body>
<script src="./jquery1.js"></script>
<script>
    var timer=null;
    var oldTndex = -1;
    $("li").mouseover(function () {
        clearTimeout(timer);
        var index = $(this).index();
        $("li").slice(0, index + 1).css("background-image", "url(./star_fill.png)");
        $("li").slice(index + 1).css("background-image", "url(./star.png)");
    })
        .mouseout(function () {
            timer = setTimeout(function () {
                $("li").slice(0, oldTndex + 1).css("background-image", "url(./star_fill.png)");
                $("li").slice(index + 1).css("background-image", "url(./star.png)");
            }, 200);
        })
        $("li").click(function(){
            oldTndex=$(this).index()
        })
</script>
</html>